package com.senac.service;

import com.mysql.jdbc.StringUtils;
import com.senac.exception.GerenciamentoEscolaException.ERROR;
import com.senac.exception.ProfessorException;
import com.senac.model.Professor;

public class ProfessorValidate {

	public static void validateProfessor(Professor professor) throws ProfessorException {
		
		if(StringUtils.isNullOrEmpty(professor.getNome())) {
			ProfessorException ex = new ProfessorException(ERROR.USER_NAME_INVALID_LENGTH);
			throw ex;
		}
		
		if(professor.getCargaHoraria() < 0) {
			ProfessorException ex = new ProfessorException(ERROR.CARGA_HORARIA_INVALID);
			throw ex;
		}
		
		if(professor.getTitulacao() == null) {
			ProfessorException ex = new ProfessorException(ERROR.TITULACAO_INVALID);
			throw ex;
		}
		
		if(!new ProfessorService().verifyNome(professor.getNome(), professor.getId())) {
			ProfessorException ex = new ProfessorException(ERROR.USER_NAME_EXIST);
			throw ex;
		}
		
	}
	
}
